
<template>
	<!-- 添加弹框 -->
	<el-dialog title=""   :visible.sync="dialogTableVisible" :modal-append-to-body="false" class="wrap"  @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">学生添加管理</div>

		<el-form label-width="100px" class="form">
			<el-form-item label="学号" class="select-block">
				<el-input v-model="vxh" placeholder="请输入学号" icon="add" ></el-input>
			</el-form-item>
 			<el-form-item label="中文名" class="select-block">
 				<el-input v-model="vzwm" placeholder="请输入中文名" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="英文名" class="select-block">
 				<el-input v-model="vywm" placeholder="请输入英文名" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="电话" class="select-block">
 				<el-input v-model="vdh" placeholder="请输入电话" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="性别" class="select-block">
				<el-select v-model="vxb"  placeholder="请选择性别" icon="add"  >
						  <el-option label="男" value="男"></el-option>
							<el-option label="女" value="女" ></el-option>
				</el-select>
 			</el-form-item>
 			<el-form-item label="是否启用" class="select-block">
				<el-select v-model="visqy"  placeholder="请选择类型" icon="add"  >
						  <el-option label="启用" value="Y"></el-option>
							<el-option label="禁用" value="N" ></el-option>
				</el-select>
 			</el-form-item>
 			<el-form-item label="出生日期" class="select-block">
 				<el-input v-model="vcsrq" placeholder="请输入出生日期" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="父母电话" class="select-block">
 				<el-input v-model="vfmdh" placeholder="请输入父母手机号" icon="add" ></el-input>
 			</el-form-item>
			<el-form-item label="微信号码" class="select-block">
 				<el-input v-model="vwx" placeholder="请输入微信号" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="招生来源" class="select-block">
 				<el-input v-model="vzsly" placeholder="请输入招生来源" icon="add" ></el-input>
 			</el-form-item>

 			<el-form-item label="家庭地址" class="select-block">
 				<el-input v-model="vjtdz" placeholder="请输入家庭地址" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="公立学校" class="select-block">
 				<el-input v-model="vglxx" placeholder="请输入公立学校" icon="add" ></el-input>
 			</el-form-item>
 			<el-form-item label="年级班级" class="select-block">
 				<el-input v-model="vnjbj" placeholder="请输入年级班级" icon="add" ></el-input>
 			</el-form-item>
			<!-- <el-form-item label="预设班级" class="select-block">
					<el-select v-model="ysbjid" placeholder="请选择..." >
						<el-option :label="v.mc" :value="v.id" v-for="v in ysbjList"></el-option>
					</el-select>
			</el-form-item> -->
 			<el-form-item label="缴费定金" class="select-block">
 				<el-input v-model="yuer" placeholder="请输入缴纳定金" icon="add" ></el-input>
 			</el-form-item>
 	</el-form>
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				vdh: '',
				vmm: '',
				vxb: '',
				vzwm: '',
				vywm: '',
				visqy: '',
				vcsrq: '',
				vzsly: '',
				vfmdh: '',
				vwx: '',
				vjtdz: '',
				vglxx: '',
				vnjbj: '',
				yuer:'',
				vxh: '',
				ysbjid:'',
				dialogTableVisible: true,
				ysbjList:[]
			}
		},
		created () {
			// this.ysbj();
			this.ysbjid = this.params.row.id
		},
		methods: {
			// ysbj(){
			// 	var logininfo = JSON.parse(localStorage.logininfo);
			// 	this.axios.get( this.$store.state.api + 'ysbj/list',{
			// 		params:{
			// 			yhid: logininfo.id,
			// 			xxid:logininfo.xxid
			// 		}
			// 	})
			// 	.then( res => {
			// 			console.log(res)
			// 			this.ysbjList = res.data.data;
			// 	}).catch( res => {
			// 			console.log(res)
			// 	})
			// },
			submit() {
				//检测
				this.$store.state.loading = true;
			   /* if(!this.mc) {
					this.$message.warning('请填写分类名称');
					this.$store.state.loading = false;
					return;
				} */
		var logininfo = JSON.parse(localStorage.logininfo);
		var params3 = qs.stringify({
			id: this.vid,
			dh: this.vdh,
			mm: this.vmm,
			xb: this.vxb,
			zwm: this.vzwm,
			ywm: this.vywm,
			isqy: this.visqy,
			csrq: this.vcsrq,
			zsly: this.vzsly,
			fmdh: this.vfmdh,
			wx: this.vwx,
			jtdz: this.vjtdz,
			glxx: this.vglxx,
			njbj: this.vnjbj,
			xh: this.vxh,
			ysbjid:this.ysbjid,
			yuer:this.yuer,
			yhid: logininfo.id,
			xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xs/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					}),

					this.axios.get( this.$store.state.api + 'ysbj/updatexs',{
						params:{
							id:this.ysbjid,
							yhid: logininfo.id,
							xxid:logininfo.xxid
						}
					})
					.then( res => {
							console.log(res)
					}).catch( res => {
							console.log(res)
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
.wrap {
	text-align: center;
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}

.select-block {
	// display: block;
	float: left;
	width: 45%;
}

.submit {
	width: 120px;
}
</style>
